import { IsBoolean, IsOptional, IsUrl, MaxLength } from 'class-validator'
import { IsOptionalString, ValidateWebhookHeaders } from '@boticord/common'
import { Limits } from '@boticord/consts'

export class UpdateWebhookSettingsDto {
  @IsOptional()
  @IsBoolean()
  declare enabled?: boolean

  @IsOptional()
  @ValidateWebhookHeaders({ message: 'Invalid webhook headers' })
  declare headers?: Record<string, string>

  @IsOptionalString()
  @IsUrl({
    require_protocol: true,
    protocols: [ 'https', 'http' ],
  })
  @MaxLength(Limits.MaxWebhookUrlLength)
  declare url?: string
}